home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <winb.h>
- #include <te.h>
- #include <fntb.h>
- #include <gui.h>
- #include <egb.h>
- #include <guidbg.h>
-
- char *guiEgbPtr ; /* EGB のワークアドレス */
-
- int DialogID = -1 ;
- int TIconID = -1 ;
- int MessageID = -1 ;
- int IconID = -1 ;
-
- #include <eintm.h>
- #include <msdos.cf>
-
- /*= リジューム用設定=================================================*/
- FRAME RSM_FRAME;
- char RSMID[]="%%% 速度 %%%";
- char RSMTITLE[]="速度 By 機拡";
-
- int quitFuncRet = ILLEGAL_FUNCTION ;
- int mode = 1; // mode 0:Normal 1:Fast
- int sleepFlag = FALSE;
-
- int userFunc(apliId, messId, info, data)
- int apliId;
- int messId;
- int info;
- int data;
- {
- register int ret;
-
- ret = ILLEGAL_FUNCTION;
-
- switch(messId)
- {
- case GM_QUIT :
- case GM_PURGE :
- // printf("終了\n");
- MMI_SendMessage( IconID, MM_EXEC, 2, 0, 0 );
- ret = quitFuncRet ;
- break;
- case GM_WAKE :
- // printf("起きる\n");
- MMI_SendMessage( DialogID, MM_ENABLE, 1, TRUE);
- MMI_SendMessage( DialogID, MM_SHOW, 0);
- sleepFlag = TRUE;
- break;
- case GM_SLEEP :
- if(sleepFlag==TRUE){
- // printf("寝る\n");
- MMI_SendMessage( DialogID, MM_ENABLE, 1, FALSE);
- MMI_SendMessage( DialogID, MM_SHOW, 0);
- }
- // else printf("寝れない\n");
- break;
-
- default : break;
- }
-
- return(ret);
- }
-
- void main()
- {
- static MMICTRL mmi ={
- SCREEN16 | SCREENIGNORE, // ページ0側解像度
- SCREENUNUSED, // ページ1側解像度
- 0, // 書き込みページ
- SCREENAVAILABLE, // 表示ページ
- 0, // 表示プライオリティ
- SCREENAVAILABLE, // 色数
- SCREENEXPAND, // VRAMの横の長さ
- 0, // メモリ領域の大きさ
- NULL, // メモリ領域のアドレス
- 0, // ユーザ領域の大きさ
- NULL, // ユーザ領域のアドレス
- 0, 0, // 画面枠 lupx,lupy
- 0, 0, // rdwx,rdwy
- -16384, -16384, // 移動枠 lupx,lupy
- 16383, 16383, // rdwx,rdwy
- 15, // 白色
- 8, // 黒色
- 7, // 灰色
- 6 // 反転色
- };
-
- extern int APL_init() ;
- extern int APL_end() ;
-
- /* 初期化処理 */
- if (MMI_Open( &mmi ) == NOERR)
- {
- /* 初期化に成功すればメインループに入る. */
- if (APL_init() == NOERR){
- MMI_ExecSystem() ;
- APL_end();
- }
- }
-
- /* 終了処理 */
- MMI_Close() ;
-
- }
-
- int APL_init()
- {
- extern MMIINIT initDataGUI ;
-
- register int ret ;
-
- /* EGB ワークアドレスの取得. */
- guiEgbPtr = MMI_GetEgbPtr() ;
-
- /* ハイパ型部品の初期化 */
- if ((ret = MMI_initHyper()) < 0)
- return ret ;
- /* ダイアログ型部品の初期化 */
- if ((ret = MMI_initDialogL40()) < 0)
- return ret ;
- /* メッセージ型部品の初期化 */
- if ((ret = MMI_initMessageL40()) < 0)
- return ret ;
- /* ボタン型部品の初期化 */
- if ((ret = MMI_initButtonL40()) < 0)
- return ret ;
- /* アイコンボタン型部品の初期化 */
- if ((ret = MMI_initIconL40()) < 0)
- return ret ;
- /* トグルアイコン型部品の初期化 */
- if ((ret = MMI_initToggleIconL40()) < 0)
- return ret ;
-
- /* 背景データの初期化 */
-
- /* データの登録 */
- if ((ret = MMI_Init(&initDataGUI)) < 0)
- return ret ;
-
- /* Tmenuにパレットを合わせる */
- EIN_initGuiColor();
-
- /*----------------------------------------------------------------*/
- /* リジューム読み込み (※のついた処理は必ず行ってください) */
- /*----------------------------------------------------------------*/
- char work[RSMWORKSIZE]; // リジュームマネージャのワークエリア
- char buf[200];
- char *ptr;
- int size, x, y;
- HYPER hyp;
-
- // リジュームマネージャの初期化
- EIN_rsmInit( work, RSMID );
- // 読み込みバッファ設定
- EIN_rsmBufSet( work, buf, 200 );
- // リジューム情報読み込み
- size = EIN_rsmLoad( work );
- #ifdef DEBUG
- printf(" resume size(%d)\n",size);
- #endif
- if ( size > 0 ){
- // 表示位置
- if ( ((ptr = strstr(buf,"\nPANEL: ")) != NULL ) &&
- (sscanf(ptr,"\nPANEL: %d %d\n", &x, &y) > 1 ) ){
- // 枠座標を得る
- MMI_SendMessage( DialogID, MM_GETHYPER, 1, &hyp );
- RSM_FRAME.lupx = x;
- RSM_FRAME.lupy = y;
- RSM_FRAME.rdwx = x+(hyp.fr.rdwx-hyp.fr.lupx);
- RSM_FRAME.rdwy = y+(hyp.fr.rdwy-hyp.fr.lupy);
- #ifdef DEBUG
- printf("PANEL: move to (%d,%d)\n", x, y);
- #endif
- MMI_SendMessage( DialogID, MM_MOVE, 1, &RSM_FRAME ) ;
- }
- } else {
- #ifdef DEBUG
- printf("Can't find resume file.\n");
- #endif
- }
-
- //起動時はFASTモードにする
- Registers.AX.LH.H = 0x08 ;
- Registers.AX.LH.L = 1 ;
- callint( 0xaf );
- MTL_setFlagObj( TIconID , MS_TOGGLE );
- MMI_SendMessage(MessageID,MM_SETMSG,1,(int)"Fast ");
- //起動時は選択できる
- // MMI_SendMessage( DialogID, MM_ENABLE, 1, TRUE);
-
- // printf("表示\n");
- /* 背景を表示する */
- MMI_SendMessage(MMI_GetBaseObj(), MM_SHOW, 0) ;
- sleepFlag = FALSE;
-
- MMI_SendMessage(MMI_GetBaseObj(), MM_SETEXEC, 1, userFunc);
- MMI_CallMessage(MMI_GetApliId(), GM_TITLE, (int)RSMTITLE, 0);
-
- return NOERR ;
- }
-
- /* initDataGUI:TIconID:MJ_TICONL40の呼び出し関数 */
- int TIconFunc(kobj, messId, argc, pev, trigger)
- int kobj ;
- int messId ;
- int argc ;
- EVENT *pev ;
- int trigger ;
- {
- mode = 1 - mode;
- if( trigger & MS_EVKEYONL40 ){
- if(mode == 0) MTL_resetFlagObj( TIconID , ~(MS_TOGGLE) );
- else MTL_setFlagObj( TIconID , MS_TOGGLE );
- // printf("S.KEY\n");
- MMI_SendMessage( TIconID , MM_SHOW , 0);
- }
-
- MMI_SendMessage(MessageID,MM_SETMSG,1,
- (int)( (mode==0) ? "Normal" : "Fast "));
- MMI_SendMessage(MessageID,MM_SHOW,0);
-
- Registers.AX.LH.H = 0x08 ;
- Registers.AX.LH.L = mode ;
- callint( 0xaf );
- return NOERR ;
- }
-
- /* initDataGUI:IconID:MJ_ICONL40の呼び出し関数 */
- int quitFunc(kobj, messId, argc, pev, trigger)
- int kobj ;
- int messId ;
- int argc ;
- EVENT *pev ;
- int trigger ;
- {
- MMI_SetHaltFlag( TRUE );
- quitFuncRet = NOERR ;
- return NOERR ;
- }
-
- int APL_end()
- {
- /*===================================================================*/
- /* リジューム情報更新 (※がついた処理は必ず行って下さい) */
- /*===================================================================*/
- char work[RSMWORKSIZE];
- char buf[200];
- char aplpath[128];
- HYPER hyp;
- register int ret;
-
- // 枠座標を得る
- MMI_SendMessage( DialogID, MM_GETHYPER, 1, &hyp );
-
- // 移動していたらセーブ
- if ( (RSM_FRAME.lupx != hyp.fr.lupx) ||
- (RSM_FRAME.lupy != hyp.fr.lupy) ){
- // マネージャ初期化
- EIN_rsmInit( work, RSMID );
- // バッファ設定(アプリ識別ID,更新時刻は自動設定されます)
- EIN_rsmBufSet( work, buf, 200 );
- // アプリディレクトリ保存
- MMI_CallMessage( MMI_GetApliId(), GM_QUERYID, QM_PATH, (int)aplpath );
- EIN_rsmBufPrintf( work, "APLPATH: %s", aplpath );
- // アプリ名保存
- EIN_rsmBufPrintf( work, "TITLE: %s", RSMTITLE );
- // コメント保存
- EIN_rsmBufCat( work, "COMMENT: 動作モードを切り換える事しかできない能無しです。常駐する意味無し。");
- // アイコン位置保存
- EIN_rsmBufPrintf( work, "PANEL: %d %d", hyp.fr.lupx, hyp.fr.lupy );
- // バッファ終端(^A)設定
- EIN_rsmBufTail( work );
- // バッファをセーブ
- ret = EIN_rsmSave( work );
- #ifdef DEBUG
- printf(" resume save size(%d) ptr:(%d,%d)\n",ret, hyp.fr.lupx, hyp.fr.lupy);
- #endif
- }
-
- return NOERR ;
- }